import type { UserSettings, Note, NoteFolder, NoteHistory } from '@/types'

// 初始化相关
export const readyService = {
  readySettings: () => window.bnote.ready.settings(),
  readyFileSpace: () => window.bnote.init.readyFileSpace()
}

// 设置相关
export const settingsService = {
  loadSettings: () => window.bnote.settings.load(),
  saveSettings: (settings: UserSettings) => window.bnote.settings.save(settings)
}

// 笔记空间相关
export const notebookService = {
  selectPath: () => window.bnote.notebook.selectPath(),
  hasNotes: (path: string) => window.bnote.notebook.hasNotes(path),
  migrate: (oldPath: string, newPath: string) => window.bnote.notebook.migrate(oldPath, newPath)
}

// 笔记相关
export const noteService = {
  loadNotes: () => window.bnote.notes.load(),
  loadNote: (noteId: string) => window.bnote.notes.load(noteId),
  saveNote: (note: Note, notebookPath: string) => window.bnote.notes.save(note, notebookPath),
  deleteNote: (noteId: string) => window.bnote.notes.delete(noteId)
}

// 历史记录相关
export const historyService = {
  saveHistory: (history: NoteHistory) => window.bnote.history.save(history),
  getHistories: (noteId: string) => window.bnote.history.get(noteId),
  cleanHistories: (noteId: string, maxCount: number) => window.bnote.history.clean(noteId, maxCount)
}

// 文件夹相关
export const folderService = {
  loadFolders: () => window.bnote.folders.load(),
  saveFolder: (folder: NoteFolder) => window.bnote.folders.save(folder),
  deleteFolder: (id: string) => window.bnote.folders.delete(id)
}
